package de.mmis.core.base;

/**
 * simple structure containing three floating point numbers that can represent a position or a dimension of an object in 2- or 3-dimensional space
 * @author Christian Koch
 *
 */
public class Position {

	public double x;
	public double y;
	public double z;
	
	/**
	 * creates new position [0,0,0]
	 */
	public Position() {
		this(0,0,0);
	}
	
	/**
	 * creates new position [x,y,0]
	 */
	public Position(double x, double y) {
		this(x,y,0);
	}
	
	/**
	 * creates new position [x,y,z]
	 */
	public Position(double x, double y, double z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	public double getX() {
		return this.x;
	}
	public void setX(double x) {
		this.x = x;
	}
	public double getY() {
		return this.y;
	}
	public void setY(double y) {
		this.y = y;
	}
	public double getZ() {
		return this.z;
	}
	public void setZ(double z) {
		this.z = z;
	}
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(this.x);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(this.y);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(this.z);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Position other = (Position) obj;
		if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x))
			return false;
		if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y))
			return false;
		if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "["+this.x+","+this.y+","+this.z+"]";
	}
}
